package com.jrzh.db.migration.sys;

import com.eroi.migrate.Define;
import com.eroi.migrate.Define.DataTypes;
import com.jrzh.framework.migration.BaseMigration;
import com.jrzh.framework.migration.MigrationHelper;

/**
 * 增加系统资源表
 * @author Mr.Shower
 *
 */
public class Migration_1 extends BaseMigration{
	
	private static final String TABLE_NAME = "sys_resources";
	
	@Override
	public void down() {
		log.info("##########回滚Sys模块 Migration_1##########");
		MigrationHelper.dropTable(TABLE_NAME);
		MigrationHelper.dropTreeColumns(TABLE_NAME);
	}

	@Override
	public void up() {
		log.info("##########执行Sys模块 Migration_1##########Begin");
		table(TABLE_NAME, "系统资源表", true,
				pk(),
				column("_pid", "父ID", DataTypes.CHAR, Define.length(36)),
				column("_code", "编号", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_type", "类型[1.菜单,2.功能,3.动作]", DataTypes.VARCHAR, Define.length(128)),
				column("_icon", "图标", DataTypes.VARCHAR, Define.length(128)),
				column("_name", "名称", DataTypes.VARCHAR, Define.length(256)),
				column("_url", "链接地址", DataTypes.VARCHAR, Define.length(256)),
				column("_remark", "备注", DataTypes.VARCHAR, Define.length(512))
		);
		MigrationHelper.addTreeColumns(TABLE_NAME);
		log.info("##########执行Sys模块 Migration_1##########End");
	}

}
